package com.igeek.javase.ch04.ordersByTeacher;

/**
 * @author chenmin
 * 2023/7/14 9:06
 * @description 订单信息
 */

public class Orders {

    private String no;

    //一对一关联  用户信息  （双向关联）
    private User user;
    //一对多关联  商品信息
    private Goods[] goods;

    //查看订单详情
    public void showOrderDetail(){
        System.out.println("订单号："+no);
        System.out.println("下单者："+user.getName());
        System.out.println("=====商品信息=====");
        if(goods!=null){
            for (Goods good : goods) {
                if(good!=null){
                    good.showGoods();
                }
            }
        }
    }

    public Orders() {
    }

    public Orders(String no, User user, Goods[] goods) {
        this.no = no;
        this.user = user;
        this.goods = goods;
    }

    /**
     * 获取
     * @return no
     */
    public String getNo() {
        return no;
    }

    /**
     * 设置
     * @param no
     */
    public void setNo(String no) {
        this.no = no;
    }

    /**
     * 获取
     * @return user
     */
    public User getUser() {
        return user;
    }

    /**
     * 设置
     * @param user
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * 获取
     * @return goods
     */
    public Goods[] getGoods() {
        return goods;
    }

    /**
     * 设置
     * @param goods
     */
    public void setGoods(Goods[] goods) {
        this.goods = goods;
    }

    /*public String toString() {
        return "Orders{no = " + no + ", user = " + user + ", goods = " + Arrays.toString(goods) + "}";
    }*/
}
